﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cache_ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 6; i++)
            {
                Console.WriteLine($"------第{i}次请求------");
                int result = 0;
                //key的名字一定要确保请求的准确性 DataSource GetDataByDB 666缺一不可
                string key = "DataSource_GetDataByDB_666";

                //将需要执行的获取数据操作编写成委托传入方法(重点)
                //Func<int> func = new Func<int>(() => { return Cache.GetDataByDB(6); });

                result = CacheHelper.GetCache(key, () => Cache.GetDataByDB(6));
                Console.WriteLine($"第{i}次请求获得的数据为：{result}");
            }

            Console.WriteLine("Hello World!");
        }
    }
}
